package com.chen.time.triggers;

import com.chen.time.timing.Animator;
import com.chen.time.timing.TimingListener;

public class TimingTrigger extends Trigger implements TimingListener {

    public static TimingTrigger addTrigger(Animator source, Animator target, TimingTriggerEvent event) {
        return addTrigger(source, target, event, false);
    }

    public static TimingTrigger addTrigger(Animator source, Animator target, TimingTriggerEvent event,
            boolean autoReverse) {
        TimingTrigger trigger = new TimingTrigger(target, event, autoReverse);
        source.addTimingListener(trigger);
        return trigger;
    }

    public TimingTrigger(Animator animator, TimingTriggerEvent event) {
        this(animator, event, false);
    }

    public TimingTrigger(Animator animator, TimingTriggerEvent event, boolean autoReverse) {
        super(animator, event, autoReverse);
    }

    @Override
    public void timingEvent(float fraction) {
    }

    @Override
    public void begin() {
        fire(TimingTriggerEvent.START);
    }

    @Override
    public void end() {
        fire(TimingTriggerEvent.STOP);
    }

    @Override
    public void repeat() {
        fire(TimingTriggerEvent.REPEAT);
    }
}
